//
//  cutils.h
//  OJ
//
//  Created by wangrui on 14-9-19.
//  Copyright (c) 2014年 PPS. All rights reserved.
//

#ifndef __OJ__cutils__
#define __OJ__cutils__

#include <stdio.h>

extern void printArray(int a[], int count);
extern void swap(int *a, int *b);

typedef int bool;
#define true 1;
#define false 0;

/***********************************************************
 *********************** queue *****************************
 ***********************************************************/

#define QUEUE_API extern

struct Queue{
	
	struct Queue *init;
	struct Queue *head;
	struct Queue *tail;
	struct Queue *next;
	
	void *data;
};

typedef struct Queue * queue_t;

QUEUE_API void init_queue(queue_t *q);
QUEUE_API void destory_queue(queue_t q);
QUEUE_API void enqueue(queue_t q, void *data);
QUEUE_API void * dequeue(queue_t q, int *status);

QUEUE_API  void * const get_head(queue_t q);
QUEUE_API  void * const get_tail(queue_t q);

QUEUE_API int is_empty_queue(queue_t q);


/***********************************************************
 *********************** stack *****************************
 ***********************************************************/
#define STACK_API extern

struct StackNode {
	struct StackNode *next;
	struct StackNode *pre;
	void *data;
};

struct Stack {
	struct StackNode *head;
	struct StackNode *tail;
};

typedef struct Stack *c_stack_t;

STACK_API c_stack_t createStack();
STACK_API void destory_tack(c_stack_t stack);
STACK_API void push(c_stack_t stack,void *data);
STACK_API void * pop(c_stack_t stack);
STACK_API int is_empty_stack(c_stack_t stack);

#endif /* defined(__OJ__cutils__) */



